package de.baumann.browser.adapter;

import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import de.baumann.browser.OdinGlideModule;
import de.baumann.browser.R;
import de.baumann.browser.api.net.vo.Packet;
/**
*@author:
*@date:2019/7/10 11:33
*@discription: 红包记录适配器
*/
public class PackAdapter extends BaseQuickAdapter<Packet, BaseViewHolder> {

    private int type;

    public PackAdapter(int layoutResId, int type) {
        super(layoutResId);
        this.type = type;
    }

    @Override
    protected void convert(BaseViewHolder helper, Packet item) {
        ImageView ivPackCover = helper.getView(R.id.ivPackCover);
        OdinGlideModule.loadWithCropAndCircle(mContext, item.getImgUrl(), ivPackCover, R.drawable.icon_head);
        helper.setText(R.id.tvPackTitle, item.getDescription());
        TextView tvAssistance = helper.getView(R.id.tvAssistance);
        if (type == 0) {
            helper.setText(R.id.tvPackAmount, "+ " + item.getAmount());
            tvAssistance.setText(String.format("%s%s", mContext.getString(R.string.boost), item.getAssistanceAmount()));
        } else {
            helper.setText(R.id.tvPackAmount, "- " + item.getAmount());
            tvAssistance.setText(String.format("%s%s", mContext.getString(R.string.Review_time), item.getCheckTime()));
        }
        helper.setText(R.id.tvPackTime, item.getDate());
    }
}
